package cn.edu.ctbu.lddweb.service.lmpl;

import cn.edu.ctbu.lddweb.mapper.ScoreMapper;
import cn.edu.ctbu.lddweb.service.ScoreService;
import cn.edu.ctbu.lddweb.pojo.Score;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 成绩管理实现层
 */
@Service
public class ScoreServicelmpl implements ScoreService {

    @Autowired
    private ScoreMapper scoreMapper;

    @Override
    public List<Score> selectList(Score score) {
        return scoreMapper.selectList(score);
    }

    /**
     * 检查是否唯一
     * @param score
     * @return
     */
    @Override
    public Boolean checkScoreUnique(Score score) {
        int id = score.getId()==0?-1:score.getId();
        Score info = scoreMapper.checkScoreUnique(score);
        if(info!=null&&info.getId()!=id){
            return true;
        }
        return false;
    }

    @Override
    public Score findID(@Param("id") int id) {
        return scoreMapper.findID(id);
    }

    @Override
    public int insertScore(Score score) {
        return scoreMapper.insertScore(score);
    }

    @Override
    public int updateScore(Score score) {
        return scoreMapper.updateScore(score);
    }

    @Override
    public int deleteScore(String id) {
        return scoreMapper.deleteScore(id);
    }

    @Override
    public List<Score> selectScore_T(Score score) {
        return scoreMapper.selectScore_T(score);
    }

    @Override
    public int updateScore_T(Score score) {
        return scoreMapper.updateScore_T(score);
    }

    @Override
    public List<Score> selectScore_S(Score score) {
        return scoreMapper.selectScore_S(score);
    }
}
